package com.lanqiao;

import com.lanqiao.Detect;

import java.io.File;

public class Detect implements Runnable {
    public static String[] str = {"未插入","aa"};
    File[] file = File.listRoots() ;
    @Override
    public void run() {
        while (true){
            System.out.println(str[0]);

            boolean dt = false ;
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            File[] files = File.listRoots();
            if (files.length!=file.length){
                for (int i = 0; i <files.length ; i++) {
                    int a = 0 ;
                    for (int j = 0; j <file.length ; j++) {
                        if (files[i].getAbsolutePath().equals(file[j].getAbsolutePath())){
                            continue;
                        }
                        a++ ;
                        if (a==file.length){
                            str[0] = files[i].getAbsolutePath();
                            str[1] = "a" ;
                            System.out.println(str[0]);
                            dt = true ;
                        }

                    }
                }
            }
            if (dt){
                break;
            }

        }

    }
}


